package net.ddns.xcyyds.kungfu.procedures;

import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.tags.ItemTags;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.network.chat.TextComponent;

public class FirstProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
		if (entity == null)
			return;
		if (!((entity.getPersistentData().getString("NO2")).equals("L") || (entity.getPersistentData().getString("NO2")).equals("R"))) {
			if ((entity.getPersistentData().getString("NO1")).equals("L") || (entity.getPersistentData().getString("NO1")).equals("R")) {
				if (entity instanceof Player _player && !_player.level.isClientSide())
					_player.displayClientMessage(new TextComponent("\u00A7c\u65E0\u6CD5\u91CA\u653E\u8FD9\u79CD\u62DB\u5F0F\uFF01"), (true));
			} else {
				if (entity instanceof Player _player && !_player.level.isClientSide())
					_player.displayClientMessage(new TextComponent("\u00A7c\u4F60\u6CA1\u6709\u91CA\u653E\u4EFB\u4F55\u62DB\u5F0F\uFF01"), (true));
			}
		} else {
			if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY)
					.is(ItemTags.create(new ResourceLocation("forge:jian")))
					&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY)
							.is(ItemTags.create(new ResourceLocation("forge:one_hand")))) {
				OneHandJianProcedure.execute(world, x, y, z, entity);
			} else {
				if (entity instanceof Player _player && !_player.level.isClientSide())
					_player.displayClientMessage(
							new TextComponent(
									"\u00A7c\u8BF7\u4E0D\u8981\u5728\u6301\u63E1\u6B64\u7C7B\u7269\u54C1\u65F6\u4F7F\u7528\u6B66\u529F\uFF01"),
							(true));
			}
			if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == (ItemStack.EMPTY).getItem()
					&& (entity instanceof LivingEntity _livEnt ? _livEnt.getOffhandItem() : ItemStack.EMPTY).getItem() == (ItemStack.EMPTY).getItem()
					|| (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY)
							.is(ItemTags.create(new ResourceLocation("forge:quan_tao")))
							&& (entity instanceof LivingEntity _livEnt ? _livEnt.getOffhandItem() : ItemStack.EMPTY)
									.is(ItemTags.create(new ResourceLocation("forge:quan_tao")))
					|| (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == (ItemStack.EMPTY).getItem()
							&& (entity instanceof LivingEntity _livEnt ? _livEnt.getOffhandItem() : ItemStack.EMPTY)
									.is(ItemTags.create(new ResourceLocation("forge:quan_tao")))
					|| (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY)
							.is(ItemTags.create(new ResourceLocation("forge:quan_tao")))
							&& (entity instanceof LivingEntity _livEnt ? _livEnt.getOffhandItem() : ItemStack.EMPTY).getItem() == (ItemStack.EMPTY)
									.getItem()) {
				QuanFaProcedure.execute(world, x, y, z, entity);
			} else {
				if (entity instanceof Player _player && !_player.level.isClientSide())
					_player.displayClientMessage(
							new TextComponent(
									"\u00A7c\u8BF7\u4E0D\u8981\u5728\u6301\u63E1\u6B64\u7C7B\u7269\u54C1\u65F6\u4F7F\u7528\u6B66\u529F\uFF01"),
							(true));
			}
		}
	}
}
